<template>
  <div class="factoryInfo">
    <el-form class="custom_form" ref="formRef" :model="form" size="large" label-width="180">
      <el-card shadow="never">
        <template #header><el-icon><User /></el-icon>注册人信息</template>
        <el-form-item label="姓名" prop="registerName">
          <el-input v-model="form.registerName" type="text" readonly></el-input>
        </el-form-item>
        <el-form-item label="身份证号" prop="registerIdCard">
          <el-input v-model="form.registerIdCard" type="text" readonly></el-input>
        </el-form-item>
        <el-form-item label="电话" prop="registerPhone">
          <el-input v-model="form.registerPhone" type="text" readonly></el-input>
        </el-form-item>
      </el-card>
      <el-card shadow="never">
        <template #header><el-icon><OfficeBuilding /></el-icon>公司信息</template>
        <el-form-item label="公司名称" prop="merchantName">
          <el-input v-model="form.merchantName" type="text" readonly></el-input>
        </el-form-item>
        <el-form-item label="法人身份证复印件" prop="corporationIdFront">
          <upload-img v-model="form.corporationIdFront" uploadIcon="zcytIcon zcyt-shenfenzhengzhengmian" iconSize="100" width="400" height="220" useScan iswatch></upload-img>
        </el-form-item>
        <el-form-item prop="corporationIdBack">
          <upload-img v-model="form.corporationIdBack" uploadIcon="zcytIcon zcyt-shenfenzhengfanmian" iconSize="100" width="400" height="220" useScan iswatch></upload-img>
        </el-form-item>
        <el-form-item label="logo" prop="merchantLogo">
          <upload-img v-model="form.merchantLogo" uploadIcon="zcytIcon zcyt-brand" iconSize="60" useScan iswatch></upload-img>
        </el-form-item>
        <el-form-item label="省市区县" prop="region">
          <region-select v-model="form.regions" size="large"></region-select>
        </el-form-item>
        <el-form-item label="详细地址" prop="addrs">
          <el-input v-model="form.addrs" type="text" readonly></el-input>
        </el-form-item>
      </el-card>
    </el-form>
  </div>
</template>

<script setup name="factoryInfo">
  import { getFactoryInfoApi } from '@/api/api'
  import { ref, getCurrentInstance } from 'vue'

  const currentThis = getCurrentInstance().appContext.config.globalProperties
  let form = ref({
    registerName: '',
    registerIdCard: '',
    registerPhone: '',
    merchantName: '',
    corporationIdFront: '',
    corporationIdBack: '',
    merchantLogo: '',
    province: '',
    city: '',
    region: '',
    addrs: '',
    regions: []
  })

  init()
  function init() {
    getFactoryInfoApi().then(res => {
      if(res.code === '200') {
        form.value = res.data
        form.value.regions = [res.data.province, res.data.city, res.data.region]
      } else {
        currentThis.$message.error(res.message)
      }
    })
  }
</script>

<style lang="less" scoped>
.factoryInfo{
  padding: 15px 20%;
  :deep(.el-form){
    .el-card{
      &:first-child{
        margin-bottom: 15px;
      }
      .el-card__header{
        display: flex;
        align-items: center;
        .el-icon{
          margin-right: 5px;
        }
      }
      .el-card__body{
        padding: 40px 80px 20px 0;
        .el-form-item{
          margin-bottom: 30px;
        }
      }
    }
  }
}
</style>